package org.leetcode.easy;

import org.leetcode.utils.ListNode;

public class ReverseList {
    public ListNode reverseList(ListNode head) {
        if(head == null && head.next == null) {
            return head;
        }
        ListNode current = head;
        ListNode newHead = null;
        while (current.next != null) {
            ListNode temp = current.next;
            newHead.next = temp;
            current.next = temp.next;
            temp.next = current;
            current = current.next;
        }
        return null;
    }
}
